package com.spring.boot.util;

/**
 * 学历枚举
 * 
 * @author YHQ
 * 
 */
public enum EduEnum {
	Junior(0, "初中"), Senior(1, "高中"), College(2, "大专"), Undergraduate(3, "本科"), Master(4, "硕士"),Doctor(5,"博士");
	private int index;
	private String eduName;

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public String getEduName() {
		return eduName;
	}

	public void setEduName(String eduName) {
		this.eduName = eduName;
	}

	private EduEnum() {

	}

	private EduEnum(int index, String eduName) {
		this.index = index;
		this.eduName = eduName;
	}

	/**
	 * 根据下标获取学历
	 * 
	 * @param index
	 * @return
	 * @author YHQ
	 * @date 2015-12-30 下午3:26:39
	 */
	public static String getEduNameByIndex(int index) {
		for (EduEnum edu : EduEnum.values()) {
			if (edu.getIndex() == index) {
				return edu.getEduName();
			}
		}
		return "";
	}

	/**
	 * 根据学历获取下标
	 * 
	 * @param eduName
	 * @return
	 * @author YHQ
	 * @date 2015-12-30 下午3:26:39
	 */
	public static int getIndexByEduName(String eduName) {
		for (EduEnum edu : EduEnum.values()) {
			if (edu.getEduName().equals(eduName)) {
				return edu.getIndex();
			}
		}
		return 0;
	}

}
